package com.spring.controller;

import com.spring.pojo.Book;
import com.spring.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BookController {
    @Autowired
    BookService bookService;

    @GetMapping("/book")
    public void book(){
        Book b1=new Book();
        b1.setName("青城山");
        b1.setAuthor("万世仔");
        int add=bookService.addBook(b1);
        System.out.println("addBook>>>>>"+add);
        Book b2=new Book();
        b2.setId(1);
        b2.setName("朝花夕拾");
        b2.setAuthor("周树人");
        int update=bookService.updateBook(b2);
        System.out.println("updateBook>>>>>"+update);
        Book b3=bookService.getBookById(1);
        System.out.println("getBookById>>>>"+b3);
        int delete=bookService.deleteBook(3);
        System.out.println("deleteBook>>>>"+delete);
        List<Book> list=bookService.getAllBook();
        System.out.println("getAllBook>>>>"+list);
    }
}
